package com.wsn.smarthouse;


import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
	private Intent intent;
	private Button btn1;
	private Button btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn1=(Button)findViewById(R.id.button1);
        btn1.setOnClickListener(new Button.OnClickListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent().setAction(
						"com.wsn.smarthouse.broadcast").putExtra("yun",
								"yumen");
				sendBroadcast(intent);
			}
        
        });
        
        btn2=(Button)findViewById(R.id.button2);
        btn2.setOnClickListener(new Button.OnClickListener(){

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent().setAction(
						"com.wsn.smarthouse.broadcast").putExtra("dingyue",
								"dingyue");
				sendBroadcast(intent);
			}
        
        });
        
        intent =  new Intent ( MainActivity.this, NetService.class );
		startService(intent);
    }
    
    @Override 
    protected void onDestroy(){
    	stopService(intent);
    	super.onDestroy();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    
}
